<template>
	<!-- <div class="home">
		<img alt="Vue logo" src="../assets/logo.png">
    <HelloWorld msg="Welcome to Your Vue.js App"/>
	</div> -->
	<view class="">
		<h1>姓名：{{userInfo.name}}</h1>
		<h1>年龄：{{newAge}}</h1>
		<button @click="changName()">修改name</button>
	</view>
</template>

<script>
	// @ is an alias to /src
	// import HelloWorld from '@/components/HelloWorld.vue'
// import store from "@/store"
import indexApi from "@/api/indexApi"

	export default {
		name: 'HomeView',
		components: {
			// HelloWorld
		},
		mounted() {
			this.toGetMenuOne()
		},
		computed: {
			userInfo() {
				return this.$store.state.userInfo
			},
			newAge(){
				return this.$store.getters.userInfoNewAge
			}
		},
		methods: {
			toGetMenuOne() {
				indexApi.getMenuOne().then(res => {
					if (res.code == 1) {
						console.log('获取成功');
					}
				})
			},
			changName(){
				// 派发修改的动作
				// this.$store.dispatch('changName','小胡')
				this.$store.commit('userInfo',{name:'小华',age:15})
			},
		}
	}
</script>